<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>写新闻的列表</title>
    <link href="../../css/admin/style.css" rel="stylesheet" type="text/css" />
    <script src="../../js/jquery-1.8.3.min.js" type="text/javascript"></script >
    <script>
        $(function (){
            $.get("../../journalism/getjournalismByWriter",function (res){
                console.log(res);
                if (res.code == 202){
                    window.parent.location.replace("../login.html");
                }else if (res.code == 500){
                    alert(res.msg);
                }else {
                    var str=""
                    for (let i = 0; i < res.data.length; i++) {
                        var imgsrc =  "http://127.0.0.1:8080/userImg/"+res.data[i].writer.account+"/"+res.data[i].coverimage;
                        str += "<tr align='center'>";
                        str+="<td>"+res.data[i].title+"</td>";
                        str+="<td>"+res.data[i].summary+"</td>";
                        str+="<td>"+ (new Date(res.data[i].publishTime).toLocaleString())+"</td>";
                        str+="<td><img src='"+imgsrc+"' width='50' height='30'/></td>";
                        str+="<td>"+res.data[i].newstype.journame+"</td>";
                        var state1
                        if (res.data[i].state==0){
                            state1 = "保存"
                        }else if (res.data[i].state==1) {
                            state1 = "未审核"
                        }else if (res.data[i].state==2) {
                            state1 = "审核通过"
                        }else if (res.data[i].state==3) {
                            state1 = "审核不通过"
                        }
                        str+="<td>"+state1+"</td>";
                        str+="<td><a href='javaScript:void(0)' onclick='viewArticle("+res.data[i].id+")' class='tablelink'>修改</a></td> "
                        str+="</tr>";
                    }
                    $("#tableId").append(str);
                }
            },"json")
        })

        function viewArticle(id){
            location.replace("update.html?id="+id)
        }
        function add(){
            location.assign("write.html");
        }

    </script>
</head>
<body>
<div class="rightinfo">
    <!-- 顶部按钮 -->
    <div class="tools">
        <ul class="toolbar">
            <a href="javaScript:void(0)" onclick="add()">
                <li class="click">
                    <span><img src="../../img/admin/t01.png"/></span>
                    添加文章
                </li>
            </a>

        </ul>
    </div>
    <!--数据列表 -->
    <table class="tablelist" id="tableId">
        <tr>
            <th >标题</th>
            <th >摘要</th>
            <th >发布时间</th>
            <th >封面图</th>
            <th >文章类型</th>
            <th >状态</th>
            <th >操作</th>
        </tr>
    </table>
</div>
</body>
</html>